package com.gglx.net
{
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.events.SecurityErrorEvent;
	import flash.net.URLLoader;
	import flash.net.URLRequest;

	public class GGURLLoader extends URLLoader
	{
		public var request:URLRequest;
		public var result:Function;
		public var error:Function;

		public function GGURLLoader(request:URLRequest=null)
		{
			addEventListener(Event.COMPLETE, onComplete, false, 0, true);
			addEventListener(IOErrorEvent.IO_ERROR, onIoError, false, 0, true);
			addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError, false, 0, true);

			this.request=request;

			super(this.request);
		}

		protected function onSecurityError(event:SecurityErrorEvent):void
		{
			trace("");
		}

		protected function onIoError(event:IOErrorEvent):void
		{
			trace("");
		}

		protected function onComplete(event:Event):void
		{
			if (result != null)
			{
				result.call(null, event.target.data);
			}
		}
	}
}
